__author__ = 'B0bY'

import pickle
import my_ner
import en_ner

def Singleton(klass):
    if not klass._instance:
        klass._instance = klass()
    return klass._instance

def load_pickle(filename):
    pkl_file = open(filename, 'rb')
    bin = pickle.load(pkl_file)
    pkl_file.close()
    return bin

class NER_EN_Loader:
    _instance = None
    per = None
    loc = None
    org = None
    def __init__(self):
        self.per = load_pickle("binary/ne_per_en.pickle")
        self.loc = load_pickle("binary/ne_loc_en.pickle")
        self.org = load_pickle("binary/ne_org_en.pickle")
    def pickle_person(self):
        return self.per
    def pickle_location(self):
        return self.loc
    def pickle_organization(self):
        return self.org

class NER_MY_Loader:
    _instance = None
    per = None
    loc = None
    org = None
    def __init__(self):
        self.per = load_pickle("binary/ne_per_my.pickle")
        self.loc = load_pickle("binary/ne_loc_my.pickle")
        self.org = load_pickle("binary/ne_org_my.pickle")
    def pickle_person(self):
        return self.per
    def pickle_location(self):
        return self.loc
    def pickle_organization(self):
        return self.org

class ES_EN_Loader:
    _instance = None
    sent = None
    def __init__(self):
        self.sent = load_pickle("binary/es_chunker_en.pickle")
    def pickle_sentiment(self):
        return self.sent

class ES_MY_Loader:
    _instance = None
    sent = None
    def __init__(self):
        self.sent = load_pickle("binary/es_chunker_id.pickle")
    def pickle_sentiment(self):
        return self.sent